#ifndef SCENE_OBJECT_HPP
#define SCENE_OBJECT_HPP

//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <string>
#include <map>
#include <vector>
#include <Math/Matrix.hpp>
#include <Rendering/Enumeration.hpp>
#include <Rendering/BatchRender.hpp>
#include <Rendering/Shader.hpp>
#include <Geometry/Mesh.hpp>
#include <Tools/SmartPointer.hpp>

namespace Geometry {

//-----------------------------------------------------------------------------
class Object;
typedef Tools::SmartPointer<Object> TObjectPointer;
//-----------------------------------------------------------------------------
class Scene {
public:	
	// Constructor
	Scene();
	// Destructor
	~Scene();
	// Get scene bound
	//const TAABBPointer& GetWorldBound() const;
	// Add object to the scene		
	void AddObject( const TObjectPointer& object);
	// Render scene's objects
	void Render(Rendering::RenderingPass pass, Rendering::RenderingQueue& queue );
protected:
	// Type definition
	typedef std::vector<TObjectPointer> TObjecttPointerVector;
	// Constructor
	Scene(const Scene& copy);
	Scene& operator=(const Scene& copy);
	// Attributs	
	TObjecttPointerVector objects;
};
//-----------------------------------------------------------------------------
class Object {
public:		
	// Destructor
	virtual ~Object();
	// Get scene bound
	//const TAABBPointer& GetWorldBound() const;
	// Get local to world transformation
	const Matrix::Matrix4& GetLocalToWorldTransformation() const;
	// Add rendering pass
	void AddPass( Rendering::RenderingPass pass, 
				  const Rendering::TShaderProgramPointer& shader,
				  const Rendering::TIShaderContextPointer& publicContext, 
				  const Rendering::TIShaderContextPointer& privatecContext );
	// Render object
	void Render(Rendering::RenderingPass pass, Rendering::RenderingQueue& queue);
	// Create object
	static TObjectPointer CreateObject(const Matrix::Matrix4& localToWorld, const TMeshPointer& mesh);
protected:
	// Constructor
	Object(const Matrix::Matrix4& localToWorld, const TMeshPointer& mesh);
	// Type definition
	typedef std::map<Rendering::RenderingPass, Rendering::TShaderEnvironnementPointer> TEnvironnementPointerMap;
	// Constructor
	Object(const Object& copy);
	Object& operator=(const Object& copy);
	// Attributs
	TMeshPointer mesh;
	Matrix::Matrix4 localToWorldMatrix;
	TEnvironnementPointerMap environnements;
};
//-----------------------------------------------------------------------------
}

#endif //SCENE_OBJECT_HPP
